import {
  elInput,
  elSelect,
  elRadioGroup,
  elUpload
} from '@/components/BaseForm/predefine'
export const getFormItems = () => {
  return [
    [{ label: '投诉层级', key: 'tier', type: elSelect,
      on: {
        change(event, form) {
          console.log('支持事件定义', event, form)
        }
      },
      options: [
        { label: '显示', value: true },
        { label: '隐藏', value: false }
      ] }],
    [{ label: '投诉对象', key: 'target', type: elInput,
      on: {
        input(e) {
          console.log(e)
        }
      },
      ifRender(form) {
        return form.tier
      } }],
    [{ label: '投诉类型', key: 'type', type: elSelect }],
    [
      {
        label: '投诉标题',
        key: 'title',
        type: elInput,
        props: { maxlength: 20 }
      }
    ],
    [
      {
        label: '投诉内容',
        key: 'content',
        type: elInput,
        props: { type: 'textarea' }
      }
    ],
    [{ label: '联系方式', key: 'phone', type: elInput }],
    [{ label: '附件', key: 'accessory', type: elUpload,
      props: {
        multiple: true,
        limit: 6,
        action: 'https://life.eshimin.com/coss/upload',
        allowFileTypes: ['application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'image/jpeg', 'image/jpg', 'image/png'],
        allowFileTypesStr: 'pdf、doc、xls、jpeg、jpg、png',
        size: 20
      }}],
    [
      {
        label: '是否匿名',
        key: 'isAnonymous',
        type: elRadioGroup,
        defaultVal: 0,
        options: [
          { label: '是', value: 1 },
          { label: '否', value: 0 }
        ]
      }
    ]
  ]
}

export const getRules = () => {
  return {
    tier: [{ required: true, message: '请选择投诉层级', trigger: 'change' }],
    target: [
      { required: true, message: '请选择投诉对象', trigger: 'blur' }
    ],
    type: [{ required: true, message: '请选择投诉类型', trigger: 'change' }],
    title: [{ required: true, message: '请输入投诉标题', trigger: 'blur' }],
    content: [
      { required: true, message: '请输入投诉内容', trigger: 'blur' }
    ],
    isAnonymous: [
      { required: true, message: '请选择是否匿名', trigger: 'blur' }
    ]
  }
}
